//
//  ViewController.m
//  Hive
//
//  Created by 惠俊贝 on 15/8/18.
//  Copyright (c) 2015年 ZM. All rights reserved.
//

#import "ViewController.h"
#import "UserAccount.h"
#import "ABNetworkUtil.h"
#import "AreaScope.h"
#import "PathViewController.h"

#define token @"nEqAF+avORwTDZ5584X1RR4+ZsbV8ET20NJpXfZaMKxzin+riZXfJhiHVPlBj1X2pmFDNtt/ArqHkrmwJhEt6tZo45BqUJ0IytPlWE9VUH5sySx1Ussg6WB+fZnli6/0cKU/EKC+aizi0j8nsScbUxSoJ00ehPpSZQ31IYvMN0c="

#define deviceid @"755177DE133665"
#define deviceid2 @"C92E969D132991"

@interface ViewController () {
    AreaScope *scope;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    
    scope = [[AreaScope alloc] init];
    scope.ID = @"5b2af4d15d1a4096b1237d72a78edd58";
    scope.AreaName = @"abe测试围栏";
    scope.UserID = @"5E5293A1BAFF429BA98F0D080BC0335B";
    scope.AreaType = @"ROUND";
    scope.ParameterSets = @"119.324545,31.2323455|40000";
    scope.State = NO;//1
    scope.Remark = @"";
    scope.InOrOut = NO;
    scope.DeviceID = deviceid2;
    

//    [self test1];
//    [self test2];
//    [self test3];
//    [self test4];
//    [self test5old];
//    [self test5];
//    [self test6];
//    [self test7];
//    [self test8];
//    [self test9];
//    [self test10];
//    [self test11];
//    [self test12];
//    [self test13];
//    [self test14];
    
//    [self test15];
//    [self test16];
//    [self test17];
//    [self test18];
//    [self test19];
    
    
    
    PathViewController *toController = [[PathViewController alloc] init];
    toController.title = @"轨迹";
    [self.navigationController pushViewController:toController animated:YES];
    
    
    
    //    [self getOffesetUTCTimeSOAP];
    
}

- (void)test1 {
    UserAccount *user = [[UserAccount alloc] init];
    user.UserName = @"supplier";
    user.Password = @"123456";
    [[[ABNetworkUtil alloc] init] loginWithUserAccount:user
                                               success:^(id response) {
                                                   
                                               } fail:^(NSError *error) {
                                                   
                                               }];
}
- (void)test2 {
    [[[ABNetworkUtil alloc] init] getParentUserInfoWithToken:token
                                                     success:^(id response) {
                                                         
                                                     } fail:^(NSError *error) {
                                                         
                                                     }];
}
- (void)test3 {
    [[[ABNetworkUtil alloc] init] getSelfUserEqpInfoWithToken:token
                                                      success:^(id response) {
                                                          
                                                      } fail:^(NSError *error) {
                                                          
                                                      }];
}
- (void)test4 {
    [[[ABNetworkUtil alloc] init] setPasswordWithOldPWD:@"12456"
                                             withNewPWD:@"123456"
                                              withToken:token
                                                success:^(id response) {
                                                  
                                              } fail:^(NSError *error) {
                                                  
                                              }];
}
- (void)test5old {
    [[[ABNetworkUtil alloc] init] getTrackInfoByIMEI:@"133665"
                                                 success:^(id response) {
                                                     
                                                 } fail:^(NSError *error) {
                                                     
                                                 }];
}
- (void)test5 {
    [[[ABNetworkUtil alloc] init] getTrackInfoByDeviceID:deviceid
                                                 success:^(id response) {
                                                     
                                                 } fail:^(NSError *error) {
                                                     
                                                 }];
}
- (void)test6 {
    [[[ABNetworkUtil alloc] init] getResponseGPSReplyWithDeviceID:deviceid
                                                        startTime:@"2015-08-27 02:56:28"
                                                          endTime:@"2015-8-30 14:56:36"
                                                          success:^(id response) {
                                                              
                                                          } fail:^(NSError *error) {
                                                              
                                                          }];
}
- (void)test7 {
    [[[ABNetworkUtil alloc] init] addAreaScope:scope
                                       success:^(id response) {
                                           
                                       } fail:^(NSError *error) {
                                           
                                       }];
}
- (void)test8 {
    [[[ABNetworkUtil alloc] init] delAreaScope:scope
                                       success:^(id response) {
                                           
                                       } fail:^(NSError *error) {
                                           
                                       }];
}
- (void)test9 {
    [[[ABNetworkUtil alloc] init] modifyAreaScope:scope
                                          success:^(id response) {
                                              
                                          } fail:^(NSError *error) {
                                              
                                          }];
}
- (void)test10 {
    [[[ABNetworkUtil alloc] init] queryAreaScopeWithDeviceID:deviceid2
                                                     success:^(id response) {
                                                         
                                                     } fail:^(NSError *error) {
                                                         
                                                     }];
}
- (void)test11 {
    //???://
    [[[ABNetworkUtil alloc] init] getAlarmsByUserID:@"5E5293A1BAFF429BA98F0D080BC0335B"
                                       andAlarmType:@"ROUND"
                                          startTime:@"2015-8-27 02:56:28"
                                            endTime:@"2015-8-30 14:56:36"
                                            success:^(id response) {
                                                
                                            } fail:^(NSError *error) {
                                                
                                            }];
}
//???://
- (void)test12 {
    [[[ABNetworkUtil alloc] init] getAlarmsByUserID:@"5E5293A1BAFF429BA98F0D080BC0335B"
                                          startTime:@"2015-08-27 02:56:28"
                                            endTime:@"2015-08-30 14:56:36"
                                            success:^(id response) {
                                                
                                            } fail:^(NSError *error) {
                                                
                                            }];
}
- (void)test13 {
    [[[ABNetworkUtil alloc] init] getAlarmsByDeviceID:deviceid
                                         andAlarmType:@"ROUND"
                                            startTime:@"2015-08-27 02:56:28"
                                              endTime:@"2015-8-30 14:56:36"
                                              success:^(id response) {
                                                  
                                              } fail:^(NSError *error) {
                                                  
                                              }];
}
- (void)test14 {
    [[[ABNetworkUtil alloc] init] getAlarmsByDeviceID:deviceid
                                            startTime:@"2015-08-27 02:56:28"
                                              endTime:@"2015-8-30 14:56:36"
                                              success:^(id response) {
                                                  
                                              } fail:^(NSError *error) {
                                                  
                                              }];
}
- (void)test15 {
    [[[ABNetworkUtil alloc] init] addAlarmsUserTel:@""
                                           telList:nil
                                           success:^(id response) {
                                               
                                           } fail:^(NSError *error) {
                                               
                                           }];
}
- (void)test16 {
    [[[ABNetworkUtil alloc] init] queryDataLib:@"AlarmType"
                                       success:^(id response) {
                                           
                                       } fail:^(NSError *error) {
                                           
                                       }];
}
- (void)test17 {
    [[[ABNetworkUtil alloc] init] getWeiZhangCitysuccess:^(id response) {
        
    } fail:^(NSError *error) {
        
    }];
}
- (void)test18 {
    [[[ABNetworkUtil alloc] init] getHplzsuccess:^(id response) {
        
    } fail:^(NSError *error) {
        
    }];
}
- (void)test19 {
    [[[ABNetworkUtil alloc] init] getWeizhangCity:@"S1X_JinZhong"
                                             hphm:@"晋KLV007"
                                             hpzl:@"02"
                                         engineno:@""
                                          classno:@""
                                         registno:@""
                                          success:^(id response) {
                                              
                                          } fail:^(NSError *error) {
                                              
                                          }];
}
- (void)getOffesetUTCTimeSOAP {
    
    //封装soap请求消息
    NSString *username = @"supplier";
    NSString *password = @"123456";
    NSString *soapMessage =[NSString stringWithFormat:
                            @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                            @"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                            @"<soap:Body>\n"
                            @"<GetLogin xmlns=\"http://tempuri.org/\">\n"
                            @"<User>\n"
                            @"<UserName>%@</UserName>\n"
                            @"<Password>%@</Password>\n"
                            @"</User>\n"
                            @"</GetLogin>\n"
                            @"</soap:Body>\n"
                            @"</soap:Envelope>"
                            ,username,password];
    // 请求发送到的URL
    NSURL *url = [NSURL URLWithString:@"http://121.41.123.146:8024/customer.asmx"];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    NSString *msgLength = [NSString stringWithFormat:@"%d", (int)[soapMessage length]];
    // 对请求信息添加属性,这是必有的，第五句是soap信息。
    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue: @"http://tempuri.org/GetLogin" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
    // 请求
    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    if(!theConnection)
        NSLog(@"theConnection is NULL");
    
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
